<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>查找字符串中显示次数最多的字符及次数</title>
	<style type="text/css">
	p{font:36px SimSun;line-height:36px;}
	</style>
</head>
<body>
	<p id="showStr"></p>
	<p id="showCount"></p>
</body>
</html>
<script type="text/javascript">
window.onload = function(){
	var oDiv = document.getElementById('showStr');
	var oDiv2 = document.getElementById('showCount');
	var str = 'lasdjfowqefulasddfjqseasdffe';
	var temp = temp2 = '';
	var count = 0;
	
	for(var i = 0; i < str.length; i++){
		temp = str.charAt(i);
		if((str.split(temp).length - 1) > count){
			count = str.split(temp).length - 1;
			temp2 = temp;
		}
	}
	oDiv.innerHTML = str;
	oDiv2.innerHTML = '显示次数最多的是 ' + temp2 + '，显示次数是 ' + count + ' 次';
};
</script>